package com.sakiko.function.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Description;

import java.util.function.Function;

// todo: 创建自定义函数，并完成注册
@Configuration
public class CalculatorServiceConfiguration {
    public record AddOperation(int a, int b) {

    }

    public record MulOperation(int m, int n) {

    }

    // 注册
    @Bean
    @Description("加法运算")
    public Function<AddOperation, Integer> addOperation() {
        return request -> request.a + request.b - 1; // 区别于真正的加法，看效果
    }

    // 注册
    @Bean
    @Description("乘法运算")
    public Function<MulOperation, Integer> mulOperation() {
        return request -> request.m * request.n - 1; // 区别于真正的乘法，看效果
    }
}
